// TYLunarCalendar
//
// Copyright (c) 2017 wty21cn <wty21cn@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import Foundation

public struct TYLunarCalendar {

    /// Calendar used for calculate date components in lunar calendar
    /// Identifier is .chinese
    private var lunarCalendar: Calendar

    /// Calendar used for calculating date in several APIs which directly take in date component
    /// Identifier is .gregorian
    private var solarCalendar: Calendar

    /// An enumeration for the various components of a lunar calendar date.
    /// Several `TYLunarCalendar` APIs use either a single unit or a set of units as input to a search algorithm.
    /// - seealso: `TYLunarDateComponents`
    public enum Component {
        case lunarYear
        case lunarMonth
        case lunarDay
        case weekDay
        case zodiac
        case solarTerm
        case lunarFestival
    }

    /// The first weekday of the calendar.
    public var firstWeekday: Int {
        set { lunarCalendar.firstWeekday = newValue }
        get { return lunarCalendar.firstWeekday }
    }

    /// The number of minimum days in the first week.
    public var minimumDaysInFirstWeek: Int {
        set { lunarCalendar.minimumDaysInFirstWeek = newValue }
        get { return lunarCalendar.minimumDaysInFirstWeek }
    }

    public init() {
        lunarCalendar = Calendar(identifier: .chinese)
        solarCalendar = Calendar(identifier: .gregorian)
    }
}

extension TYLunarCalendar {
    public var zodiacSymbols: [String] { return Array(TYLunarDateComponent.Zodiac.symbols.values) }

    public var lunarYearSymbols: [String] { return Array(TYLunarDateComponent.LunarYear.symbols.values)}

    public var lunarMonthSymbols: [String] { return Array(TYLunarDateComponent.LunarMonth.symbols.values)}

    public var lunarDaySymbols: [String] { return Array(TYLunarDateComponent.LunarDay.symbols.values)}
}